package server

import (
	"CDSystem/v2/config"
	"CDSystem/v2/route"
	"path/filepath"

	"github.com/gin-gonic/gin"
)

var App = &Server{}

const (
	HTTP = iota
	HTTPS
)

type Server struct {
}

func (*Server) Start(ip, port, mode string) {
	gin.SetMode(mode)
	gin.DefaultWriter = config.OutputWriter
	route.RH.Engine = gin.Default() //返回默认的路由引擎
	route.RH.InitRender(filepath.Join(config.Cfg.System.CurrentDir, "templates"))
	route.RH.SetHandler()
	route.RH.Engine.Run(ip + ":" + port)
}
